package com.github.prontera;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.github.prontera.domain.EventSubscriber;
import com.github.prontera.domain.enums.EventStatus;
import com.google.common.base.Preconditions;

/**
 * @author Alex
 */
public class NopeEventHandler extends EventHandler {

	private static final Logger LOGGER = LoggerFactory.getLogger(NopeEventHandler.class);

	@Override
	public void handle(EventSubscriber subscriber) {
		Preconditions.checkNotNull(subscriber);
		Preconditions.checkNotNull(subscriber.getId());
		if (mapper.updateEventStatusByPrimaryKeyInCasMode(subscriber.getId(), EventStatus.NEW, EventStatus.NOT_FOUND) > 0) {
			LOGGER.error("event which id is {} has to change status from NEW to NOT_FOUND due to threr is not a match handler.", subscriber.getId());
		}
	}

}
